<div class="loader"></div>
<h3>
@if ( $enable_update ) {{ $text_edit }} @else {{ $text_view }}  @endif
{{ $title }} with ID# {{ $result->id }}</h3>

{{ Form::model($result, array('route' => array($base . '.update', $result->id), 'method' => 'PUT', 'id' => 'form')) }}
<div class="row">
	<div class="col-md-3"><strong>{{ $text_po_number }}</strong></div>
	<div class="col-md-9">{{ strtoupper($result->vendor->code) }}-{{ str_pad($result->id, 3, '0', STR_PAD_LEFT) }}-{{ date_format($result->created_at, 'Ymd') }}</div>
</div>
<div class="row">
	<div class="col-md-3"><strong>{{ $text_vendor }}</strong></div>
	<div class="col-md-9">{{ $result->vendor->name }}</div>
</div>
<div class="row">
	<div class="col-md-3"><strong>{{ $text_company }}</strong></div>
	<div class="col-md-9">{{ strtoupper($result->company_code) }}</div>
</div>

{{-- P. O. Creator Information --}}
<div class="row">
	<div class="col-md-3"><strong>{{ $text_created_by }}</strong></div>
	<div class="col-md-9"></strong>{{ $result->createdBy->firstname }} {{ $result->createdBy->lastname }}
	<small>{{ $text_at }}</small> {{ $result->created_at }}</div>
</div>

{{-- P. O. Modifier Information --}}
<div class="row">
	<div class="col-md-3"><strong>{{ $text_modified_by}}</strong></div>
	<div class="col-md-9">{{ $result->modifiedBy->firstname }} {{ $result->createdBy->lastname }} 
	<small>{{ $text_at }}</small> {{ $result->updated_at }}</div>
</div>

	{{-- P. O. Approver Information --}}
	@if ( $result->status == Constant::PO_APPROVED )
	<div class="row">
		<div class="col-md-3"><strong>{{ $text_approved_by }}</strong></div>
		<div class="col-md-9">{{ $result->approvedBy->firstname }} {{ $result->approvedBy->lastname }} 
			<small>{{ $text_at }}</small> {{ $result->approved_at }}</div>
		</div>
	</div>
	@endif
	
	{{-- Transfer Price --}}
	<div class="row">
		<div class="col-md-3"><strong>{{ $text_total_transfer_price }}</strong></div>
		<div class="col-md-9">{{ number_format($result->total_transfer_price,2) }}</div>
	</div>

	<br/>
	{{-- P. O. Items --}}
	@if ( !empty($po_items) )
	<table id="tbl-po-items" class="table table-bordered table-striped">
		<thead>
			<tr>
				<th></th>
				<th>Item ID</th>
				<th>Sales Order ID</th>
				<th>Product Name</th>
				<th>Quantity</th>
				<th>Options</th>
				<th>Transfer Price</th>
				<th>Received</th>
			</tr>
		</thead>
		<tbody>
	@foreach ( $po_items as $key => $item )
		<tr>
			<td>
				@if ( $item['enable_delete'] )
					<input type="checkbox" name="items[]" value="{{ $key }}"/>
				@endif
			</td>
			<td>{{ $item['item_id'] }}</td>
			<td>{{ $item['order_id'] }}</td>
			<td>{{ $item['name'] }}</td>
			<td>{{ $item['quantity'] }}</td>
			<td>
				@forelse ( $item['options'] as $key => $op )
					{{ $op['value'] }} - {{ $op['quantity'] }}
					
					@if ( $key != count($item['options']) - 1 )
						<br />
					@endif
				@empty
					N/A
				@endforelse
			</td>
			<td>{{ number_format($item['transfer_price'], 2) }}</td>
			<td>
				@if ( $item['received'] )
					{{ $text_yes }}
				@else
					{{ $text_no }}
				@endif
			</td>
		</tr>
	@endforeach

		</tbody>
	</table>
	
	
	{{-- Enable Form when PO Pending or Upon Deletion --}}
	@if ( $enable_update  )
		<div class="row">
			<div class="col-md-12">
				{{ Form::label('status', $form_status) }}
				@if ( $enable_delete )
					{{ Form::select('status', $statuses, Input::old('status'), array('class' => 'form-control', 'disabled' => 'disabled')) }}
				@else
					{{ Form::select('status', $statuses, Input::old('status'), array('class' => 'form-control')) }}
				@endif
			</div>
		</div>
		<div class="clearfix"></div>
		<br/>
		<div class="row">
			<div class="col-md-12">
				{{ Form::label('comment', $form_comment) }}
				{{ Form::textarea('comment', Input::old('comment'), array('class' => 'form-control', 'size' => '30x4')) }}
			</div>
		</div>
		<span class="error text-danger" id="error_comment"></span>
		<div class="clearfix"></div>
		<br/>
		<div class="row">
			<div class="col-md-12">
				@if ( $enable_delete )
					{{ Form::submit('Delete PO Items', array('class' => 'btn btn-success', 'id'=> 'submit', 'data-loading-text' => $text_loading)) }}
				@else
					{{ Form::submit($text_submit, array('class' => 'btn btn-primary', 'id'=> 'submit', 'data-loading-text' => $text_loading)) }}
				@endif
			</div>
		</div>		
	@endif
	<br />
@else
	<p>All P. O. Items had been archived.</p>
@endif
<div class="clearfix"></div>
{{-- Download and Cancel Buttons --}}
<div class="row">
	<div class="col-md-8">
		<a href='{{ URL::to("po/export/{$result->id}/default/1") }}' class="btn btn-primary">Download Supplier PO</a>
		<a href='{{ URL::to("po/export/{$result->id}/acommerce/1") }}' class="btn btn-primary">Download Acommerce PO</a>
		@if ( $result->status == Constant::PO_APPROVED )
			<a href='{{ URL::to("po/generate-stickers/{$result->id}/1") }}' class="btn btn-primary btn-success" style="margin: 5px;">Generate Stickers</a>
		@endif
	</div>
	<div class="col-md-4 pull-right">
		{{ HTML::link( URL::previous(), $text_close, array('class' => 'btn btn-default', 'id'=> 'cancel')) }}
	</div>
</div>
{{ Form::close() }}




